Skip to content

gh-143990: Do not assume the requested font size in test_font#153322

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-143990-test-font-actual-size
Jul 8, 2026
Merged

gh-143990: Do not assume the requested font size in test_font#153322
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-143990-test-font-actual-size

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 8, 2026

Copy link
Copy Markdown
Member

On platforms that provide only bitmap fonts (for example the AMD64 Alpine Linux buildbot) a font created from a description such as ('Times', 20, 'bold') does not keep the requested size: Tk substitutes the nearest available size. The test_create and test_existing tests added in GH-152025 asserted the exact requested size (20) and therefore failed there.

This asks Tk for the size it actually resolves for the description (via font actual) instead of assuming the requested value. The keyword/explicit-size assertions are unchanged, since those set the size directly.

🤖 Generated with Claude Code

On platforms with only bitmap fonts Tk substitutes the nearest
available size, so query the resolved size instead of assuming it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@weixlu

weixlu commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hi, I also noticed this issue shown on the Alpine buildbot, and reproduced it locally.

I've verified your fix works as well — using self.actual_size instead of the hardcoded 20 makes the test more robust. Just one thing to add: I found that if you install scalable font (via apk add font-liberation font-dejavu), then the test actually passes as-is too.

@serhiy-storchaka

Copy link
Copy Markdown
Member Author

Thank you for verification. The test was incorrect from the beginning, it should not have such assumption.

@serhiy-storchaka serhiy-storchaka merged commit 841e454 into python:main Jul 8, 2026
52 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants